package com.wgts.wgts.mvp.view.activity.myorder;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.RecyclerView;
import android.text.ClipboardManager;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.wgts.wgts.R;
import com.wgts.wgts.base.BaseActivity;
import com.wgts.wgts.control.dialog.ToastDate;
import com.wgts.wgts.control.dialog.ToastDialogFragment;
import com.wgts.wgts.control.recycleview.CustomLineaLayoutManager;
import com.wgts.wgts.control.toast.MoHuToast;
import com.wgts.wgts.dagger.ComponentHolder;
import com.wgts.wgts.dagger.component.DaggerMyOrderDetailsActivityComponent;
import com.wgts.wgts.dagger.module.MyOrderDetailsActivityModule;
import com.wgts.wgts.localbean.GoodsData;
import com.wgts.wgts.localbean.PayData;
import com.wgts.wgts.mvp.presenter.IMyOrderDetailsActivityPresenter;
import com.wgts.wgts.mvp.view.IMyOrderDetailsActivityView;
import com.wgts.wgts.mvp.view.activity.pay.ContinuePayActivity;
import com.wgts.wgts.netmodle.resp.ChangeGoodsPlanEntity;
import com.wgts.wgts.netmodle.resp.MyOrderDetailsEntity;
import com.wgts.wgts.thirdParty.pay.PayTools;
import com.wgts.wgts.tools.AppInfor;

import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/*
 *
 *     我的订单详情页
 *   data:2018/9/1014:45
 *
 */public class MyOrderDetailsActivity extends BaseActivity implements IMyOrderDetailsActivityView {
    @BindView(R.id.back_btn_image)
    ImageView backBtnImage;
    @BindView(R.id.back_btn_ly)
    LinearLayout backBtnLy;
    @BindView(R.id.include_title)
    TextView includeTitle;
    @BindView(R.id.include_text)
    TextView includeText;
    @BindView(R.id.include_right_image)
    ImageView includeRightImage;
    @BindView(R.id.include_right_ly)
    LinearLayout includeRightLy;
    @BindView(R.id.order_status)
    TextView orderStatus;
    @BindView(R.id.pay_hour)
    TextView payHour;
    @BindView(R.id.pay_minute)
    TextView payMinute;
    @BindView(R.id.pay_second)
    TextView paySecond;
    @BindView(R.id.order_title_need_pay_price)
    TextView orderTitleNeedPayPrice;
    @BindView(R.id.order_wait_pay_title_ly)
    LinearLayout orderWaitPayTitleLy;
    @BindView(R.id.logistics_company_name)
    TextView logisticsCompanyName;
    @BindView(R.id.logistics_number)
    TextView logisticsNumber;
    @BindView(R.id.logistics_copy)
    TextView logisticsCopy;
    @BindView(R.id.order_other_title_ly)
    LinearLayout orderOtherTitleLy;
    @BindView(R.id.affirm_location_image)
    ImageView affirmLocationImage;
    @BindView(R.id.affirm_user_name)
    TextView affirmUserName;
    @BindView(R.id.affirm_user_phone)
    TextView affirmUserPhone;
    @BindView(R.id.affirm_user_location)
    TextView affirmUserLocation;
    @BindView(R.id.include_order_recycle)
    RecyclerView includeOrderRecycle;
    @BindView(R.id.show_or_hidden_text)
    TextView showOrHiddenText;
    @BindView(R.id.show_or_hidden_image)
    ImageView showOrHiddenImage;
    @BindView(R.id.show_or_hidden_recycle)
    LinearLayout showOrHiddenRecycle;
    @BindView(R.id.include_order_shopping_number)
    TextView includeOrderShoppingNumber;
    @BindView(R.id.include_order_shopping_price)
    TextView includeOrderShoppingPrice;
    @BindView(R.id.include_order_shopping_freight)
    TextView includeOrderShoppingFreight;
    @BindView(R.id.include_order_storekeeper_privileges)
    TextView includeOrderStorekeeperPrivileges;
    @BindView(R.id.include_order_storekeeper_ly)
    LinearLayout includeOrderStorekeeperLy;
    @BindView(R.id.all_price_title_text)
    TextView allPriceTitleText;
    @BindView(R.id.include_order_all_price)
    TextView includeOrderAllPrice;
    @BindView(R.id.order_pay_price_ly)
    LinearLayout orderPayPriceLy;
    @BindView(R.id.include_pay_tv)
    TextView includePayTv;
    @BindView(R.id.include_order_need_pay_way)
    TextView includeOrderNeedPayWay;
    @BindView(R.id.order_pay_way_ly)
    LinearLayout orderPayWayLy;
    @BindView(R.id.order_number)
    TextView orderNumber;
    @BindView(R.id.copy)
    TextView copy;
    @BindView(R.id.include_order_time)
    TextView includeOrderTime;
    @BindView(R.id.include_order_pay_time)
    TextView includeOrderPayTime;
    @BindView(R.id.order_pay_time_ly)
    LinearLayout orderPayTimeLy;
    @BindView(R.id.order_time_ly)
    LinearLayout orderTimeLy;
    @BindView(R.id.order_cancel_tv)
    TextView orderCancelTv;
    @BindView(R.id.order_cancel_ly)
    LinearLayout orderCancelLy;
    @BindView(R.id.order_confirm_tv)
    TextView orderConfirmTv;
    @BindView(R.id.order_confirm_ly)
    LinearLayout orderConfirmLy;
    @BindView(R.id.bottom_ly)
    LinearLayout bottomLy;
    @BindView(R.id.logistics_recycle)
    RecyclerView logisticsRecycle;
    @BindView(R.id.include_logistics_Ly)
    LinearLayout includeLogisticsLy;
    @BindView(R.id.include_location_ly)
    LinearLayout includeLocationLy;
    @BindView(R.id.order_head_ly)
    LinearLayout orderHeadLy;
    @BindView(R.id.can_made_price)
    TextView canMadePrice;
    @BindView(R.id.can_made_ly)
    LinearLayout canMadeLy;
    @BindView(R.id.my_order_parent)
    FrameLayout myOrderParent;
    private CustomLineaLayoutManager lineaLayoutManager;
    private OrderDetailsRecycleAdapter detailsRecycleAdapter;

    private boolean showAll = false;

    private AfterSaleAdapter afterSaleAdapter;

    private MyOrderDetailsEntity myOrderDetailsEntity;


    //订单ID
    public static final String ORDER_ID = "orderId";
    private String orderId;
    private String status;
    //订单交易状态
    public static final String PAY_STATUS = "payStatus";
    private String payStatus;

    private PayData payData;

    @Inject
    IMyOrderDetailsActivityPresenter presenter;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_order_details_activity);
        ButterKnife.bind(this);
        Intent intent = getIntent();
        orderId = intent.getStringExtra(ORDER_ID);
        payStatus = intent.getStringExtra(PAY_STATUS);
        includeRightLy.setVisibility(View.INVISIBLE);
        includeRightLy.setClickable(false);
        initView();
    }

    @Override
    public void init() {
        DaggerMyOrderDetailsActivityComponent
                .builder()
                .appComponent(ComponentHolder.getInstance().getAppComponent())
                .myOrderDetailsActivityModule(new MyOrderDetailsActivityModule(this))
                .build()
                .inject(this);
    }

    private void initView() {
        if (orderId != null && !orderId.equals("")) {
            showDialog();
            presenter.orderDetailsResult(Integer.parseInt(orderId));
        }
    }

    @OnClick({R.id.back_btn_ly, R.id.logistics_copy, R.id.show_or_hidden_recycle, R.id.copy,
            R.id.order_cancel_ly, R.id.order_confirm_ly, R.id.include_right_ly})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back_btn_ly:
                finish();
                break;
            case R.id.logistics_copy:
                copy(logisticsNumber);
                break;
            case R.id.show_or_hidden_recycle:
                if (showAll) {
                    showAll = false;
                    presenter.getListDate(showAll);
                    showOrHiddenText.setText("展开全部商品");
                    showOrHiddenImage.setImageResource(R.mipmap.ic_public_load);
                } else {
                    showAll = true;
                    presenter.getListDate(showAll);
                    showOrHiddenText.setText("收起全部商品");
                    showOrHiddenImage.setImageResource(R.mipmap.ic_public_up);
                }
                break;
            case R.id.copy:
                copy(orderNumber);
                break;
            case R.id.order_cancel_ly:
                if (status.equals("UNPAID")) {
                    cancelOrder();
                } else {
                    afterSale();
                }
                break;
            case R.id.order_confirm_ly:
                switch (status) {
                    case "UNPAID":
                        pay();
                        break;
                    case "UNDELIVER":
                        confirmOrder();
                        break;
                    case "UNRECEIPT":
                        confirmOrder();
                        break;
                    case "UNEVALUATED":
                        goEvaluate();
                        break;
                }
                break;
            case R.id.include_right_ly:
                    //callService();
                break;
        }
    }

    //复制方法
    private void copy(TextView textView) {
        ClipboardManager cmb = (ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE);
        cmb.setText(textView.getText().toString()); //将内容放入粘贴管理器,在别的地方长按选择"粘贴"即可
        Toast.makeText(this, "复制成功", Toast.LENGTH_SHORT).show();
    }

    //去支付方法
    private void pay() {
        payData = new PayData();
        Intent intent = new Intent(MyOrderDetailsActivity.this, ContinuePayActivity.class);
        payData.orderId = myOrderDetailsEntity.orderId;
        payData.needPayPrice = myOrderDetailsEntity.orderTruePrice;
        payData.orderType = myOrderDetailsEntity.orderType;
        payData.commissionProfit = myOrderDetailsEntity.orderCommissionProfit;
        payData.orderCode = myOrderDetailsEntity.orderCode;
        intent.putExtra(PayTools.PAY_DATE, payData);
        startActivityForResult(intent, ContinuePayActivity.PAY_RESULT_OK);
    }

    //取消订单方法
    private void cancelOrder() {
        ToastDate toastDate = new ToastDate();
        toastDate.setCancelQuestion("确认取消订单？");
        toastDate.setCancelText("确认取消");
        toastDate.setPointText("我再想想");
        toastDate.setFragmentManager(getSupportFragmentManager());
        final ToastDialogFragment toastDialogFragment = ToastDialogFragment.setToastMessage(toastDate);
        toastDialogFragment.show(getSupportFragmentManager(), "CancelOrderDialog");
        toastDialogFragment.setOnClickListener(new ToastDialogFragment.OnClickListener() {
            @Override
            public void onClickCancle() {
                toastDialogFragment.dismiss();
            }

            @Override
            public void onClickEnsuer() {
                presenter.cancelOrder(myOrderDetailsEntity.orderId);
                toastDialogFragment.dismiss();
            }
        });
    }

    //确认收货方法
    private void confirmOrder() {
        ToastDate toastDate = new ToastDate();
        toastDate.setCancelQuestion("确认收货？");
        toastDate.setCancelText("取消");
        toastDate.setPointText("确认");
        toastDate.setFragmentManager(getSupportFragmentManager());
        final ToastDialogFragment toastDialogFragment = ToastDialogFragment.setToastMessage(toastDate);
        toastDialogFragment.show(getSupportFragmentManager(), "CancelOrderDialog");
        toastDialogFragment.setOnClickListener(new ToastDialogFragment.OnClickListener() {
            @Override
            public void onClickCancle() {
                presenter.takeGoods(myOrderDetailsEntity.orderId);
                toastDialogFragment.dismiss();
            }

            @Override
            public void onClickEnsuer() {
                toastDialogFragment.dismiss();
            }
        });
    }

    //立即评价方法
    private void goEvaluate() {
        Intent intent = new Intent(MyOrderDetailsActivity.this, EvaluateActivity.class);
        intent.putExtra(EvaluateActivity.ORDER_ID, orderId);
        startActivityForResult(intent, EvaluateActivity.EVALUATE_RESULT);
    }


    //申请售后方法
    private void afterSale() {
        Intent intent = new Intent(MyOrderDetailsActivity.this, AfterSaleActivity.class);
        GoodsData goodsData = new GoodsData();
        goodsData.setProductPrice("￥" + myOrderDetailsEntity.shops.get(0).products.get(0).productPrice);
        goodsData.setCount("x1");
        goodsData.setUrl(myOrderDetailsEntity.shops.get(0).products.get(0).productSmallImage);
        goodsData.setProductName(myOrderDetailsEntity.shops.get(0).products.get(0).productName);
        goodsData.setProductType(myOrderDetailsEntity.shops.get(0).products.get(0).productStandard);
        intent.putExtra(AfterSaleActivity.GOODS_DATE, goodsData);
        intent.putExtra(AfterSaleActivity.ORDER_ID, orderId);
        intent.putExtra(AfterSaleActivity.ORDER_CODE, myOrderDetailsEntity.orderCode);
        startActivityForResult(intent, ContinuePayActivity.PAY_RESULT_OK);
    }



    @Override
    public void onError(int status, String msg) {
        MoHuToast.showToast(msg);
        dialogDismiss();
    }

    @Override
    public void orderDetailsResult(MyOrderDetailsEntity entity) {
        dialogDismiss();
        myOrderDetailsEntity = entity;
        status = entity.orderState;
        showPage();
        if (entity.shops.get(0).products.size() < 2) {
            showOrHiddenRecycle.setVisibility(View.GONE);
        } else {
            showOrHiddenRecycle.setVisibility(View.VISIBLE);
        }
        presenter.getListDate(showAll);
    }

    @Override
    public void getListDate(List<MyOrderDetailsEntity.Shop> shopList) {
        lineaLayoutManager = new CustomLineaLayoutManager(this);
        lineaLayoutManager.setScrollEnabled(false);
        includeOrderRecycle.setLayoutManager(lineaLayoutManager);
        detailsRecycleAdapter = new OrderDetailsRecycleAdapter(this, shopList, myOrderDetailsEntity.orderType);
        includeOrderRecycle.setAdapter(detailsRecycleAdapter);
    }

    @Override
    public void changeOrderPlan(List<ChangeGoodsPlanEntity> planEntities) {
        CustomLineaLayoutManager lineaLayoutManager = new CustomLineaLayoutManager(this);
        lineaLayoutManager.setScrollEnabled(false);
        logisticsRecycle.setLayoutManager(lineaLayoutManager);
        afterSaleAdapter = new AfterSaleAdapter(this, planEntities);
        logisticsRecycle.setAdapter(afterSaleAdapter);
    }

    @Override
    public void changeOrderType() {
        MoHuToast.showToast("操作成功");
        Intent intent = new Intent();
        intent.putExtra("PayStatue", "success");
        setResult(ContinuePayActivity.PAY_RESULT_OK, intent);
        finish();
    }

    //根据status和payStatus处理页面的展示效果
    private void showPage() {
        myOrderParent.setVisibility(View.VISIBLE);
//        if (myOrderDetailsEntity.orderType.equals("VIP")){
//            canMadeLy.setVisibility(View.GONE);
//        }else {
//            if (AppInfor.getInstance().getUserState() > 1) {
//                canMadeLy.setVisibility(View.VISIBLE);
//                canMadePrice.setText("￥" + myOrderDetailsEntity.orderCommissionProfit);
//            } else {
//                canMadeLy.setVisibility(View.GONE);
//            }
//        }
        if (payStatus.equals("CLOSED")) {
            orderHeadLy.setBackgroundResource(R.color.order_details_head);
            includeLocationLy.setVisibility(View.VISIBLE);
            includeLogisticsLy.setVisibility(View.GONE);
            bottomLy.setVisibility(View.GONE);
            includeOrderShoppingFreight.setTextColor
                    (ContextCompat.getColor(this, R.color.black));
            orderPayTimeLy.setVisibility(View.GONE);
            orderWaitPayTitleLy.setVisibility(View.GONE);
            orderPayWayLy.setVisibility(View.VISIBLE);
            orderOtherTitleLy.setVisibility(View.GONE);
            allPriceTitleText.setText("总计");
            includeTitle.setText("已关闭");
            orderStatus.setText("订单已关闭");
        } else if (status.equals("COMPLETED") && payStatus.equals("COMPLETED")){
            orderHeadLy.setBackgroundResource(R.color.order_details_head);
            includeLocationLy.setVisibility(View.VISIBLE);
            includeLogisticsLy.setVisibility(View.GONE);
            bottomLy.setVisibility(View.GONE);
            includeOrderShoppingFreight.setTextColor
                    (ContextCompat.getColor(this, R.color.black));
            orderPayTimeLy.setVisibility(View.GONE);
            orderWaitPayTitleLy.setVisibility(View.GONE);
            orderPayWayLy.setVisibility(View.VISIBLE);
            orderOtherTitleLy.setVisibility(View.GONE);
            allPriceTitleText.setText("已支付");
            includeTitle.setText("已完成");
            orderStatus.setText("订单已完成");
        }else {
            switch (status) {
                case "UNPAID":
                    orderCancelTv.setText("取消订单");
                    orderConfirmTv.setText("去支付");
                    includeTitle.setText("待付款");
                    orderStatus.setText("待付款");
                    //订单头部LinearLayout背景色
                    orderHeadLy.setBackgroundResource(R.color.order_details_head);
                    //收货地址LinearLayout
                    includeLocationLy.setVisibility(View.VISIBLE);
                    //物流进度LinearLayout
                    includeLogisticsLy.setVisibility(View.GONE);
                    //运费
                    includeOrderShoppingFreight.setTextColor
                            (ContextCompat.getColor(this, R.color.delete_red));
                    //头部付款时间LinearLayout
                    orderWaitPayTitleLy.setVisibility(View.VISIBLE);
                    //头部物流信息LinearLayout
                    orderOtherTitleLy.setVisibility(View.GONE);
                    //底部支付时间LinearLayout
                    orderPayTimeLy.setVisibility(View.GONE);
                    //支付方式LinearLayout
                    orderPayWayLy.setVisibility(View.GONE);
                    //取消订单按钮
                    orderCancelLy.setVisibility(View.VISIBLE);
                    orderCancelLy.setBackgroundResource(R.drawable.my_order_cancle_border);
                    orderCancelTv.setTextColor(ContextCompat.getColor(this, R.color.hint_6));
                    //底部取消订单，立即支付等LinearLayout
                    bottomLy.setVisibility(View.VISIBLE);
                    break;
                case "UNDELIVER":
                    orderCancelTv.setText("申请售后");
                    orderConfirmTv.setText("确认收货");
                    includeTitle.setText("待发货");
                    orderStatus.setText("待发货");
                    orderHeadLy.setBackgroundResource(R.color.order_details_head);
                    includeLocationLy.setVisibility(View.VISIBLE);
                    includeLogisticsLy.setVisibility(View.GONE);
                    bottomLy.setVisibility(View.GONE);
                    includeOrderShoppingFreight.setTextColor
                            (ContextCompat.getColor(this, R.color.black));
                    orderPayTimeLy.setVisibility(View.VISIBLE);
                    orderWaitPayTitleLy.setVisibility(View.GONE);
                    orderPayWayLy.setVisibility(View.VISIBLE);
                    orderOtherTitleLy.setVisibility(View.GONE);
                    orderCancelLy.setVisibility(View.GONE);
                    orderCancelTv.setTextColor(ContextCompat.getColor(this, R.color.hint_6));
                    break;
                case "UNRECEIPT":
                    orderCancelTv.setText("申请售后");
                    orderConfirmTv.setText("确认收货");
                    includeTitle.setText("待收货");
                    orderStatus.setText("待收货");
                    orderHeadLy.setBackgroundResource(R.color.order_details_head);
                    includeLocationLy.setVisibility(View.VISIBLE);
                    includeLogisticsLy.setVisibility(View.GONE);
                    bottomLy.setVisibility(View.VISIBLE);
                    includeOrderShoppingFreight.setTextColor
                            (ContextCompat.getColor(this, R.color.black));
                    orderPayTimeLy.setVisibility(View.VISIBLE);
                    orderWaitPayTitleLy.setVisibility(View.GONE);
                    orderPayWayLy.setVisibility(View.VISIBLE);
                    orderOtherTitleLy.setVisibility(View.GONE);
                    orderCancelLy.setVisibility(View.GONE);
                    orderCancelTv.setTextColor(ContextCompat.getColor(this, R.color.hint_6));
                    break;
                case "UNEVALUATED":
                    orderCancelTv.setText("申请售后");
                    orderConfirmTv.setText("立即评价");
                    includeTitle.setText("待评价");
                    orderStatus.setText("待评价");
                    orderHeadLy.setBackgroundResource(R.color.order_details_head);
                    includeLocationLy.setVisibility(View.VISIBLE);
                    includeLogisticsLy.setVisibility(View.GONE);
                    bottomLy.setVisibility(View.VISIBLE);
                    includeOrderShoppingFreight.setTextColor
                            (ContextCompat.getColor(this, R.color.black));
                    orderPayTimeLy.setVisibility(View.VISIBLE);
                    orderWaitPayTitleLy.setVisibility(View.GONE);
                    orderPayWayLy.setVisibility(View.VISIBLE);
                    orderOtherTitleLy.setVisibility(View.GONE);
                    orderCancelLy.setVisibility(View.VISIBLE);
                    orderCancelLy.setBackgroundResource(R.drawable.watch_award_border);
                    orderCancelTv.setTextColor(ContextCompat.getColor(this, R.color.white));
                    break;
                case "COMPLETED":
                    orderCancelTv.setText("申请售后");
                    includeTitle.setText("已完成");
                    orderStatus.setText("已完成");
                    orderHeadLy.setBackgroundResource(R.color.order_details_head);
                    includeLocationLy.setVisibility(View.VISIBLE);
                    includeLogisticsLy.setVisibility(View.GONE);
                    bottomLy.setVisibility(View.VISIBLE);
                    includeOrderShoppingFreight.setTextColor
                            (ContextCompat.getColor(this, R.color.black));
                    orderPayTimeLy.setVisibility(View.VISIBLE);
                    orderWaitPayTitleLy.setVisibility(View.GONE);
                    orderPayWayLy.setVisibility(View.VISIBLE);
                    orderOtherTitleLy.setVisibility(View.GONE);
                    orderCancelLy.setVisibility(View.VISIBLE);
                    orderConfirmLy.setVisibility(View.GONE);
                    orderCancelLy.setBackgroundResource(R.drawable.watch_award_border);
                    orderCancelTv.setTextColor(ContextCompat.getColor(this, R.color.white));
                    break;
                case "RETURN_GOOD":
                    includeRightLy.setVisibility(View.INVISIBLE);
                    includeText.setText("联系客服");
                    includeText.setTextColor(ContextCompat.getColor(this, R.color.bulue_copy));
                    includeRightLy.setClickable(false);
                    includeTitle.setText("退换货");
                    orderStatus.setText("退换货");
                    orderHeadLy.setBackgroundResource(R.color.order_details_green);
                    includeLocationLy.setVisibility(View.GONE);
                    includeLogisticsLy.setVisibility(View.VISIBLE);
                    bottomLy.setVisibility(View.GONE);
                    includeOrderShoppingFreight.setTextColor
                            (ContextCompat.getColor(this, R.color.black));
                    orderPayTimeLy.setVisibility(View.VISIBLE);
                    orderWaitPayTitleLy.setVisibility(View.GONE);
                    orderPayWayLy.setVisibility(View.VISIBLE);
                    orderOtherTitleLy.setVisibility(View.GONE);
                    presenter.changeOrderPlan(Integer.parseInt(orderId));
                    break;
            }
        }
        orderTitleNeedPayPrice.setText(myOrderDetailsEntity.orderTruePrice);
        logisticsCompanyName.setText(myOrderDetailsEntity.expressType);
        logisticsNumber.setText(myOrderDetailsEntity.expressCode);
        affirmUserName.setText(myOrderDetailsEntity.userName);
        affirmUserPhone.setText(myOrderDetailsEntity.userPhone);
        affirmUserLocation.setText(myOrderDetailsEntity.province + " " + myOrderDetailsEntity.city +
                "" + myOrderDetailsEntity.area + " " + myOrderDetailsEntity.details);
        includeOrderShoppingNumber.setText(String.valueOf(myOrderDetailsEntity.productCount) + "件");
        includeOrderShoppingPrice.setText(myOrderDetailsEntity.orderPrice + "元");
        includeOrderShoppingFreight.setText(myOrderDetailsEntity.orderSendPrice + "元");
        //includeOrderStorekeeperPrivileges.setText("-￥" + myOrderDetailsEntity.orderDiscountPrice + "元");
        includeOrderAllPrice.setText(myOrderDetailsEntity.orderTruePrice + "元");
        switch (myOrderDetailsEntity.payType) {
            case "WXPAY":
                includeOrderNeedPayWay.setText("微信支付");
                break;
            case "ALIPAY":
                includeOrderNeedPayWay.setText("支付宝支付");
                break;
            case "BALANCEPAY":
                includeOrderNeedPayWay.setText("余额支付");
                break;
        }
        orderNumber.setText(myOrderDetailsEntity.orderCode);
        includeOrderTime.setText(myOrderDetailsEntity.createTime);
        includeOrderPayTime.setText(myOrderDetailsEntity.payTime);

    }

    private void callService(){
        ToastDate toastDate = new ToastDate();
        toastDate.setCancelQuestion("确认拨打17164809615？");
        toastDate.setPointText("确认");
        toastDate.setCancelText("取消");
        final ToastDialogFragment fragment = ToastDialogFragment.setToastMessage(toastDate);
        fragment.show(getSupportFragmentManager(), "CallServiceDialog");
        fragment.setOnClickListener(new ToastDialogFragment.OnClickListener() {
            @Override
            public void onClickCancle() {
                Intent i = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:17164809615"));
                startActivity(i);
                fragment.dismiss();
            }

            @Override
            public void onClickEnsuer() {
                fragment.dismiss();
            }
        });
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data){
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == ContinuePayActivity.PAY_RESULT_OK && data != null){
            Intent intent = new Intent();
            intent.putExtra("PayStatue", "success");
            setResult(ContinuePayActivity.PAY_RESULT_OK, intent);
            finish();
        }
        if (requestCode == EvaluateActivity.EVALUATE_RESULT && data != null){
            Intent intent = new Intent();
            intent.putExtra("Evaluate", "success");
            setResult(ContinuePayActivity.PAY_RESULT_OK, intent);
            finish();
        }
    }

}
